package com.feishi.core.util.common.lecode.thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: caixq
 * Date: 2020-08-20
 * Time: 上午11:06
 */
public class Foo {

    public Foo() {

    }
    int status=1;
    public void first(Runnable printFirst) throws InterruptedException {
        synchronized (this){
            while (status!=1)this.wait();
            printFirst.run();status++;
            this.notifyAll();
        }
    }

    public void second(Runnable printSecond) throws InterruptedException {
        synchronized (this){
            while (status!=2)this.wait();
            printSecond.run();status++;
            this.notifyAll();
        }
    }

    public void third(Runnable printThird) throws InterruptedException {
        synchronized (this){
            while (status!=3)this.wait();
            printThird.run();status++;
            this.notifyAll();
        }
    }
}